package com.hxit.huaxiamelongarden.controller;

import com.hxit.huaxiamelongarden.domin.po.Content;
import com.hxit.huaxiamelongarden.service.ContentService;
import com.hxit.huaxiamelongarden.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ContentController
 * @Author 12694
 * @Date 2025/1/23 15:45
 * @Version 1.0
 **/
@Slf4j
@RestController
@RequestMapping("/content")
public class ContentController {
    @Autowired
    private ContentService contentService;
    /*根据用户id查询帖子内容*/
    @GetMapping
    public Result getCommentsByUserId(@RequestAttribute("userId") String userId){
        log.info("userId:{}",userId);
        List<Content> commentsByUserId = contentService.getCommentsByUserId(Integer.parseInt(userId));
        return Result.success(commentsByUserId);
    }
}
